home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / C and C++ / POSIX / posixinfo.txt < prev   
Encoding:
Emacs RMAIL  |  1992-10-12  |  6.9 KB  |  247 lines  |  [TEXT/ttxt]

  1. BABYL OPTIONS:
  2. Version: 5
  3. Labels:
  4. Note:   This is the header of an rmail file.
  5. Note:   If you are seeing it in rmail,
  6. Note:    it means the file has no messages in it.
  7. 
  8. 0, unseen,,
  9. *** EOOH ***
  10. Newsgroups: comp.sys.mac.programmer
  11. Subject: Think C Posix library
  12. From: tim@maths.tcd.ie (Timothy Murphy)
  13. Date: Fri, 2 Oct 1992 17:09:08 GMT
  14. Organization: Dept. of Maths, Trinity College, Dublin, Ireland.
  15. Keywords: Think C library
  16. Summary: A small library of Posix functions
  17.  
  18.  
  19. I recently ported a number of GNU programs to the Mac --
  20. including perl-4.035, rcs-5.6, diff-2.0 and patch-2.0.12u8 --
  21. using Think C.
  22. To avoid repetition, I wrote a library 
  23. called, rather grandiosely, ThinkCPosix or just Posix.
  24. (I say "wrote", but in fact code for many of the functions
  25. was collected from PD archives.)
  26.  
  27. The following note describes what this library is,
  28. and how it can be obtained and used.
  29.  
  30. ===================== ThinkCPosix.tex ===================== 
  31. \documentstyle[rcs,a4,12pt]{article}
  32.  
  33. % rcs.sty is available from ftp.uni-stuttgart.de
  34. % in the directory soft/tex/latex-style-supported .
  35.  
  36. \RCS$Revision: 1.1 $
  37. \RCS$Date: 1992/09/14 14:28:23 $
  38.  
  39. \catcode`\"=\active
  40. \def"#1"{{\tt #1}}
  41.  
  42. \begin{document}
  43.  
  44. \title{A Posix Library for Think C}
  45.  
  46. \author{Timothy Murphy\\
  47. Trinity College Dublin\\
  48. ("tim@maths.tcd.ie")}
  49.  
  50. \date{\RCSDate\\[2mm]
  51. (Version \RCSRevision)}
  52.  
  53. \maketitle
  54.  
  55. \begin{abstract}
  56. This library is intended to supplement
  57. the ANSI and Unix libraries provided with Think C,
  58. by supplying as many of the missing Posix functions as possible.
  59. The library was developed to assist in porting
  60. GNU programs to the Macintosh\footnotemark.
  61. \end{abstract}
  62.  
  63. \footnotetext{To date the author has ported
  64. the following GNU programs to the Mac:
  65. "diff-1.15",
  66. "patch-2.012u6",
  67. "rcs-5.6",
  68. "bison-1.18",
  69. "flex-2.3.7",
  70. "perl-4.035".}
  71.  
  72. \section{Status}
  73.  
  74. This library is placed in the Public Domain.
  75. It may be used and modified freely---%
  76. though the author would be grateful
  77. for notification of any such modifications,
  78. and would prefer if his name and e-mail address
  79. were left on all files, to this end.
  80.  
  81. \section{Availability}
  82.  
  83. The library is available by anonymous FTP from "ftp.maths.tcd.ie"
  84. in the directory "pub/Mac/ThinkCPosix-1.1".
  85. The compiled library is contained in the file "Posix.hqx".
  86. The source files are archived in "ThinkCPosix.hqx".
  87. This includes the Think C project "Posix.$\pi$".
  88.  
  89. \section{Acknowledgements}
  90.  
  91. The author has used freely code in the archives
  92. pointed out to him,
  93. in particular code by:
  94. Guido van Rossum ("guido@cwi.nl"), and
  95. Mathias Neearcher.
  96. (Where code is taken more or less verbatim,
  97. this is indicated in the relevant files.)
  98.  
  99. He is also grateful for assistance from:
  100. Kenneth Seah ("kseah@procyon.austin.tx.us"),
  101. Sak Wathanasin ("sw@network-analysis-ltd.co.uk"),
  102. John W. Hardin ("hardin@mcc.com"), and
  103. Gary J. Henderson ("gary@iscnvx.lmsc.lockheed.com")
  104.  
  105. \section{Posix}
  106.  
  107. The use of the term ``Posix'' may be misleading---%
  108. it is certainly not meant to imply that the functions satisfy
  109. any Posix standards
  110. (of which the author is largely ignorant).
  111. It is intended simply as a description
  112. of the kind of functions included---%
  113. namely, those Posix functions not included
  114. in the Think C ANSI or Unix libraries.
  115.  
  116. Many of the functions
  117. (in particular those in the file "dummy.c")
  118. do no more than return an appropriate value,
  119. indicating success or failure, as deemed appropriate.
  120.  
  121. \section{Compilation}
  122.  
  123. To re-compile the library,
  124. the included project "Posix.$\pi$" can be used.
  125. Just choose the "Build Library" option
  126. in the "Project" menu.
  127.  
  128. The author has all the ANSI options turned on,
  129. as well as "Require prototypes".
  130. The 4-byte int option and 68020 code option
  131. are turned off.
  132.  
  133. \section{Usage}
  134.  
  135. Any file using the library should
  136. \begin{verbatim}
  137.       #include "ThinkCPosix.h"
  138. \end{verbatim}
  139. The header ("*.h") files should be placed somewhere
  140. in the Think C tree (ie below the Think C application).
  141.  
  142. Whenever the "Posix" library is included,
  143. the Think C "MacTraps" library must also be included.
  144. (This could probably be avoided by abstracting
  145. the very few MacTraps functions called.
  146. But is that legal?)
  147.  
  148. \section{Notes}
  149. These are a few random thoughts on some of the functions
  150. in the library.
  151.  
  152. \begin{description}
  153.  
  154. \item["alloca()"]
  155. This has been included to avoid duplication.
  156. Note that the prototype is "void *alloca(size\_t)",
  157. rather than "char *alloca(unsigned)".
  158.  
  159. \item["dup()"]
  160. The functions "dup()" and "dup2()"
  161. (as implemented here)
  162. both close the original file after duplication.
  163. The reason for this is that Think C adopts the non-standard,
  164. if plausible, policy of including some file-functions
  165. (such as "close")
  166. as part of the file structure.
  167. So a "close(fd)" addressed to the original descriptor
  168. would also close the duplicate.
  169. (This may be a misunderstanding on the author's part.)
  170.  
  171. \item["getpasswd()"]
  172. This (and one or two other functions)
  173. call "getlogin()" in the Think C Unix library
  174. to find the user's name.
  175. This latter must be set---%
  176. under System 7, at least---%
  177. in the "Sharing Setup" Control Panel,
  178. as described in the Macintosh Networking Reference manual.
  179. (I believe that under System 6 the username was changed
  180. on the Chooser panel.)
  181.  
  182. \item["Open()"]
  183. The library includes a few ``substitute'' functions,
  184. eg "Perror()" and "Open()".
  185. The idea is that these can be used in place of
  186. "perror()" or "open()" by including the line
  187. \begin{verbatim}
  188.       #define open Open
  189. \end{verbatim}
  190. (or equivalent) at a judicious point in the program---%
  191. probably at the end of the configuration file,
  192. "conf.h" or whatever.
  193.  
  194. The function "Open(char*, int, ...)"
  195. allows "open()" to take more than 2 arguments
  196. (as seems increasingly the practice),
  197. although these extra arguments are ignored.
  198.  
  199. \item["Perror()"]
  200. This gives a brief description of the error (if it can)
  201. rather than just the number as in "perror()".
  202. The Think C function "strerror()"---%
  203. which the author had not noticed---%
  204. may render this unnecessary.
  205.  
  206. \end{description}
  207.  
  208. \section{Gnu ports}
  209.  
  210. In principle the files 
  211. "patch.hqx", "diff.hqx", "perl.hqx", "ci.hqx", etc,
  212. in the directory "pub/Mac" at "ftp.maths.tcd.ie"
  213. contain the compiled applications.
  214.  
  215. The source for these applications---%
  216. or rather, the diff-files from the standard distributions---%
  217. are in the appropriate subdirectory,
  218. eg "pub/Mac/diff-2.0".
  219.  
  220. Unfortunately, none of these ports are yet documented properly.
  221.  
  222. \section{Development}
  223.  
  224. The author would be very grateful
  225. for any suggested improvements or extensions.
  226. Please send them to "tim@maths.tcd.ie".
  227. Any material used will be duly acknowledged.
  228.  
  229. Implementation of functions related to 
  230. "pipe", "exec" and "spawn"
  231. would be particularly useful.
  232. (The "exec()" function in the Think C Unix library
  233. ignores all arguments except for the application to be launched.
  234. It would be nice if these arguments could be properly passed---%
  235. as must surely be feasible.)
  236.  
  237.  
  238. \end{document}
  239. ===========================================================
  240.  
  241.  
  242. -- 
  243. Timothy Murphy  
  244. e-mail: tim@maths.tcd.ie
  245. tel: +353-1-2842366
  246. s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland
  247.